package com.example.film.controller;

import com.example.film.entity.FilmComment;
import com.example.film.service.FilmCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "电影评论信息管理接口")
@CrossOrigin
@RestController
@RequestMapping("top250film/v1")
public class FilmCommentController {

    @Autowired
    private FilmCommentService filmCommentService;

    @ApiOperation("电影评论信息")
    @GetMapping("/comments/{filmRank}")
    public List<FilmComment> getFilmCommentByRank(@PathVariable Integer filmRank){
        return filmCommentService.findFilmCommentByRank(filmRank);
    }

    @ApiOperation("分页显示电影评论")
    @GetMapping("/commentInfo")
    public List<FilmComment> getCommentInfo(@RequestParam Integer filmRank,@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize){
        return filmCommentService.findFilmCommentInfo(filmRank,pageNum,pageSize);
    }
}
